package de.hs_zigr.inf.iib08gruppe5powerfish.it;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

public class __MainQuery {

	public static void main(String args[]) throws Exception {
		String driver = "org.exist.xmldb.DatabaseImpl";
		String query = "//produktname";
		Class cl = Class.forName(driver);
		Database database = (Database) cl.newInstance();
		DatabaseManager.registerDatabase(database);

		Collection col = DatabaseManager
				.getCollection("xmldb:exist://localhost:8080/exist/xmlrpc/db/test");
		XPathQueryService service = (XPathQueryService) col.getService(
				"XPathQueryService", "1.0");
		service.setProperty("indent", "yes");

		ResourceSet result = service.query(query);
		ResourceIterator i = result.getIterator();
		while (i.hasMoreResources()) {
			Resource r = i.nextResource();
			System.out.println((String) r.getContent());
		}
	}
}
